<!DOCTYPE html>
<html lang="en">
<head>
  <meta charset="UTF-8">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <title>Document</title>
  <style>
    *{
      margin: 0;
      padding: 0;
    }
    .detail{
      width: 800px;
      height: 450px;
      background-color: #fff;
      margin: auto;
      border: 1px solid #f4f4f4;
    }
    .detail img{
      width: 350px;
      height: 403px;
      background-color: palegoldenrod;
      float: left;
    }
    .detail .right{
      float: right;
      width: 400px;
      height: 100%;
      margin-right: 25px;
      background-color: #f5f5f5;
      text-align: left;
      padding-left: 30px;
      padding-top: 20px;
      box-sizing: border-box;
    }
    .detail .right h3{
      font-size: 22px;
      font-weight: bold;
      line-height: 40px;
    }
    .detail .right span{
      font-size: 18px;
      line-height: 30px;
      color: red;
      font-weight: bold;
      margin-top: 15px;
    }
  </style>
</head>
<body>
  <!-- 商品详情 页面待完成 -->
   <div class="detail">
    <!-- <img src="" alt="">
    <div class="right">
      <h3>标题</h3>
      <span>价格</span>
    </div> -->
   </div>
</body>
<script src="./axios.js"></script>
<script>
  let oDetail=document.querySelector('.detail')
  axios.defaults.baseURL='http://localhost:8888'
  //location.search-返回url中的参数部分
  // console.log(location.search); //["?goodsid",'8']
    // console.log(location.search.split("=")); //["?goodsid",'8']
    // console.log(location.search.split("=")[1]); //'8'
  let id=Number(location.search.split("=")[1])
  // console.log(id);
  axios.get('/goods/item',{
    params:{
      id:id
    }
  }).then(res=>{
    console.log(res);
    let str=''
    
    oDetail.innerHTML=`
    <img src="${res.data.info.img_big_logo}" alt="">
    <div class="right">
      <h3>${res.data.info.title}</h3>
      <span>¥:${res.data.info.price}</span>
    </div>
    `
    //img_big_logo
  })
</script>
</html>